<!--_meta 作为公共模版分离出去-->
{include file="public/meta" /}
<!--/meta 作为公共模版分离出去-->
<title>添加管理员 - 管理员管理 - h-ui.admin.pro v1.0</title>
<meta name="keywords" content="h-ui.admin.pro v1.0,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
<meta name="description" content="h-ui.admin.pro v1.0，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
<body style="background-color:#fff">
<div class="wap-container">
    <div class="panel">
        <div class="panel-body">
            <form action="" method="post" class="form form-horizontal" id="form-admin-add">
                <input type="hidden" class="input-text" value="{$model['id']}" placeholder=""
                       name="id">
                <div class="row clearfix">
                    <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>管理员：</label>
                    <div class="form-controls col-xs-8 col-sm-9">
                        <input type="text" class="input-text" value="{$model.name}" placeholder="" id="name" name="name">
                    </div>
                </div>
                <div class="row clearfix">
                    <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>初始密码：</label>
                    <div class="form-controls col-xs-8 col-sm-9">
                        <input type="password" class="input-text" autocomplete="off" value="" placeholder="密码"
                               id="password" name="password">
                    </div>
                </div>
                <div class="row clearfix">
                    <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认密码：</label>
                    <div class="form-controls col-xs-8 col-sm-9">
                        <input type="password" class="input-text" autocomplete="off" placeholder="确认新密码" id="password2"
                               name="password2">
                    </div>
                </div>
                <div class="row clearfix">
                    <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>性别：</label>
                    <div class="form-controls col-xs-8 col-sm-9 skin-minimal">
                        <div class="radio-box">
                            <input name="sex" type="radio" value="1" id="sex-1" {if condition="$model['sex']==1 || !$model['sex']"}checked{/if}>
                            <label for="sex-1">男</label>
                        </div>
                        <div class="radio-box">
                            <input type="radio" id="sex-2" value="2" name="sex" {if condition="$model['sex']==2"}checked{/if}>
                            <label for="sex-2">女</label>
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
                    <div class="form-controls col-xs-8 col-sm-9">
                        <input type="text" class="input-text" value="{$model.phone}" placeholder="" id="phone" name="phone">
                    </div>
                </div>
                <div class="row clearfix">
                    <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱：</label>
                    <div class="form-controls col-xs-8 col-sm-9">
                        <input type="text" class="input-text" value="{$model.email}" placeholder="@" name="email" id="email">
                    </div>
                </div>
                <div class="row clearfix">
                    <label class="form-label col-xs-4 col-sm-3">角色：</label>
                    <div class="form-controls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
							<select class="select" name="role_id" size="1">
                                {volist name="group" id="vo"}
								<option value="{$vo.id}" {if condition="$model['role_id']==$vo.id"}selected{/if}>{$vo.name}</option>
                                {/volist}
							</select>
							</span></div>
                </div>
                <div class="row clearfix">
                    <label class="form-label col-xs-4 col-sm-3">备注：</label>
                    <div class="form-controls col-xs-8 col-sm-9">
                        <textarea name="remarks" cols="" rows="" class="textarea" placeholder="说点什么...100个字符以内"
                                  dragonfly="true" onKeyUp="textarealength(this,100)">{$model.remarks}</textarea>
                        <p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                        <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<!--_footer 作为公共模版分离出去-->
{include file="public/footer" /}
<!--/_footer /作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="{__STATIC_PATH}admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="{__STATIC_PATH}admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="{__STATIC_PATH}admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
    $(function () {
        /* 通过iCheck插件，美化checkbox */
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        /* 表单验证，提交 */
        $("#form-admin-add").validate({
            rules: {
                name: {
                    required: true,
                    minlength: 4,
                    maxlength: 16
                },
                sex: {
                    required: true,
                },
                role_id: {
                    required: true,
                },
                remarks: {
                    maxlength: 100,
                }
            },
            onkeyup: false,
            focusCleanup: false,
            submitHandler: function (form) {
                $.ajax({
                    url: "add",
                    type: "post",
                    data: $("form").serialize(),
                    success: function (res) {
                        if (res.code == 1) {
                            layer.msg(res.msg, {
                                icon: 1,
                                time: 1000 //2秒关闭（如果不配置，默认是3秒）
                            }, function () {
                                //do something
                                parent.location.replace(parent.location.href)
                                parent.layer.close(index);
                            });
                        } else {
                            layer.msg(res.msg, {icon: 2, time: 1000});
                        }
                    }
                })
            }
        });
    });
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
